package com.example.springboot.service.imp;

import com.example.springboot.bean.TSCourse;
import com.example.springboot.bean.TSCourseStudent;
import com.example.springboot.repository.CourseRepository;
import com.example.springboot.repository.CourseStudentRepository;
import com.example.springboot.service.CourseService;
import com.example.springboot.service.CourseStudentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;

/**
 * Created by tang on 2017/11/16.
 */
@Service
public class CourseStudentServiceImp implements CourseStudentService {

    @Resource
    CourseStudentRepository courseStudentRepository;

    @Override
    @Transactional
    public void save(TSCourseStudent courseStudent) {
        courseStudentRepository.save(courseStudent);

    }

    @Override
    @Transactional()
    public void delect(int id) {
        courseStudentRepository.delete(id);

    }

    @Override
    @Transactional
    public void update(TSCourseStudent courseStudent) {
        courseStudentRepository.save(courseStudent);
    }

    @Override
    @Transactional
    public Iterable<TSCourseStudent> getAll() {
        Iterable<TSCourseStudent> courseStudents=courseStudentRepository.findAll();
        return courseStudents;
    }
}
